package com.company.controller;

import com.company.bean.UserInfoBean;
import com.company.service.IUserService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.List;

@Controller
public class UserAjaxController {

    //依赖注入
    @Resource
    private IUserService userService;

    //@ResponseBody表示这个handel方法是按照ajax的处理流程进行处理，而不是跳转视图解析处理
    @ResponseBody
    @RequestMapping("/ajaxdemo")
    public String doAjaxDemo(String userName,String userAddress){

        System.out.println("UserName："+userName);
        System.out.println("UserAddress："+userAddress);
        //ajax请求返回的是ajax内容串；
        //普通的请求返回的是试图命名【区别】
        return "OK ";
    }


    @ResponseBody
    @RequestMapping("/ajaxdemo2")
    public List<UserInfoBean> doAjaxDemo2(String userName, String userAddress){

        System.out.println("UserName："+userName);
        System.out.println("UserAddress："+userAddress);
        //ajax请求返回的是ajax内容串；
        //普通的请求返回的是试图命名【区别】
        List<UserInfoBean> userInfoBeans = userService.selectByPrimaryKey(66);
        //查询返回结果集，springMVC框架
        return userInfoBeans;
    }
}
